a11y: handle atk race condition where widget has been destroyed
authorChristian Hergert <christian@hergert.me>
Sat, 21 Mar 2015 21:17:39 +0000 (14:17 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 22 Mar 2015 00:05:08 +0000 (20:05 -0400)
If the widget has been destroyed since a DBus message had been sent,
we could be in a condition that the widget pointer exists but it does
not have a window.

This bails as if the widget didn't exist if there is no available
GdkWindow.

We also set the extents to 0 to be defensive since this is a vfunc
implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=746586

gtk/a11y/gtktextviewaccessible.c

index d2f17e6edbbb2aa914e8e468f949b54336426176..f97c155d1d0568344e3a4ff55c441b9f8062a701 100644 (file)
@@ -509,6 +509,11 @@ gtk_text_view_accessible_get_character_extents (AtkText      *text,
   GdkWindow *window;
   gint x_widget, y_widget, x_window, y_window;
 
+  *x = 0;
+  *y = 0;
+  *width = 0;
+  *height = 0;
+
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (text));
   if (widget == NULL)
     return;
@@ -519,6 +524,9 @@ gtk_text_view_accessible_get_character_extents (AtkText      *text,
   gtk_text_view_get_iter_location (view, &iter, &rectangle);
 
   window = gtk_text_view_get_window (view, GTK_TEXT_WINDOW_WIDGET);
+  if (window == NULL)
+    return;
+
   gdk_window_get_origin (window, &x_widget, &y_widget);
 
   *height = rectangle.height;